@import '../common/style/base.less';

@rate-text-font-size: var(--td-rate-text-font-size, @font-size-m);
@rate-text-color: var(--td-rate-text-color, @text-color-disabled);
@rate-text-active-color: var(--td-rate-text-active-color, @text-color-primary);
@rate-selected-color: var(--td-rate-selected-color, @warning-color);
@rate-unselected-color: var(--td-rate-unselected-color, @component-border);
@rate-text-active-font-weight: var(--td-rate-text-active-font-weight, 600);
@rate-icon-scale: var(--td-rate-icon-scale, 1.33);

.@{prefix}-rate {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-start;

  &__wrapper {
    line-height: 1em;
    display: inline-flex;
  }

  &__icon {
    display: block;
    line-height: 1em;
    width: 1em;
    transition: transform 0.3s ease;

    &--current {
      transform: scale(@rate-icon-scale);
    }

    &--selected {
      color: @rate-selected-color;

      &-half {
        color: transparent;
        background: linear-gradient(
          to right,
          @rate-selected-color 0%,
          @rate-selected-color 50%,
          @rate-unselected-color 51%,
          @rate-unselected-color 100%
        );
        -webkit-background-clip: text;
        background-clip: text;
      }
    }

    &--unselected {
      color: @rate-unselected-color;
    }
  }

  &__text {
    font-size: @rate-text-font-size;
    color: @rate-text-color;
    margin-left: 32rpx;
    vertical-align: middle;

    &--active {
      color: @rate-text-active-color;
      font-weight: @rate-text-active-font-weight;
    }
    .sr-only();
  }

  &__tips {
    position: absolute;
    display: flex;
    align-items: center;
    bottom: calc(100% + 16rpx);
    padding: 8rpx;
    border-radius: 12rpx;
    box-shadow: @shadow-1;
    background-color: @bg-color-container;
    transform: translateX(-50%);

    &--bottom {
      top: calc(100% + 16rpx);
      bottom: auto;
    }

    &-item {
      display: flex;
      flex-direction: column;
      align-items: center;
      width: 64rpx;
      border-radius: 6rpx;

      &--active {
        background-color: @bg-color-component;
      }
    }

    &-text {
      text-align: center;
      font: @font-body-medium;
    }
  }
}
